class AdvancedLog:
    def __init__(self, params):
        if 'file' in params:
            self.file = open(params['file'], 'w+')
        else:
            self.file = sys.stdout

    def write(self, data):
        print >>self.file, data['time'], data['url'], data['response_time'], \
            data['result'], data['content']

    def close(self):
        self.file.close()
